#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project    :icac2 
@File       :utils.py
@Author     :wangfan13
@Date       :2021/5/25 16:24 
"""
import datetime

from apps.users.serializers import UserModelSerializer

def jwt_response_payload_handler(token, user=None, request=None):
    # 返回之前记录用户最后登陆时间,django默认只会记录登陆后台管理系统最后时间,JWT不记录
    user.last_login = str(datetime.datetime.today())
    user.save()
    return {
            'token': token,
            'user': UserModelSerializer(user).data
        }
